<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>v-bind指令</title>
  <script src="../vue.js"></script>
</head>

<body>
  <!-- 
    v-bind
    作用:动态的设置html中的标签属性==>src,url,title....
    v-bind简写   :src
   -->
  <div id="app">
    <img v-bind:src="imgurl" alt="">

    <hr>


    <button @click="prevImg">上一页</button>
    <!-- <button @click="index === 0 ? alert('是第一张了') : index-- ">上一页</button> -->
    <div>
      <img :src="list[index]" alt="">
    </div>
    <button @click="nextImg">下一页</button>
  </div>
  <script>
    const app = new Vue({
      el: '#app',
      data: {
        index: 0,
        imgurl: '../day01/imgs/10-01.png',
        list: [
          './imgs/11-00.gif',
          './imgs/11-01.gif',
          './imgs/11-02.gif',
          './imgs/11-03.gif',
          './imgs/11-04.png',
          './imgs/11-05.png',
        ]
      },
      methods: {
        prevImg() {
          if (this.index === 0) {
            alert('已经是第一张了')
            return
          }
          this.index--
        },
        nextImg() {
          if (this.index === 5) {
            alert('已经是最后一张了')
            return
          }
          this.index++
        }
      }
    })
  </script>
</body>

</html>